package light.head.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Formula;

/**
 * 资产变动
 * @author yy
 *
 */
@Entity
@Table
public class AssetsAlteration implements Serializable{
	
	private static final long serialVersionUID = -8386310190034903339L;
	private Integer code;
	private Integer ac;				//资产编号
	private Integer uc;				//使用者编号
	private boolean revert;			//是否归还
	private Date time1;				//使用时间
	private Date time2;				//归还时间
	private Integer cu;
	
	private String an;
	private String un;
	private String cn;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public Integer getAc() {
		return ac;
	}
	@Column
	public Integer getUc() {
		return uc;
	}
	@Column
	public boolean isRevert() {
		return revert;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column
	public Date getTime1() {
		return time1;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column
	public Date getTime2() {
		return time2;
	}
	@Column
	public Integer getCu() {
		return cu;
	}
	
	@Formula("(SELECT a.name FROM Assets a WHERE a.code = ac)")
	public String getAn() {
		return an;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = uc)")
	public String getUn() {
		return un;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cu)")
	public String getCn() {
		return cn;
	}
	
	
	
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setAc(Integer ac) {
		this.ac = ac;
	}
	public void setUc(Integer uc) {
		this.uc = uc;
	}
	public void setRevert(boolean revert) {
		this.revert = revert;
	}
	public void setTime1(Date time1) {
		this.time1 = time1;
	}
	public void setTime2(Date time2) {
		this.time2 = time2;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setAn(String an) {
		this.an = an;
	}
	public void setUn(String un) {
		this.un = un;
	}
	public void setCn(String cn) {
		this.cn = cn;
	}
	
	
}
